/*
 * $Id: TestADIFFileMaking.m 89 2009-07-15 03:36:56Z jon@bway.net $
 * Chalk
 *
 * Created 6/17/09
 * Copyright Jon Gordon
 * 
 * Permission is hereby granted, free of charge, to any person obtaining 
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including 
 * without limitation the rights to use, copy, modify, merge, publish, 
 * distribute, sublicense, and/or sell copies of the Software, and to 
 * permit persons to whom the Software is furnished to do so, subject to 
 * the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#import "TestADIFFileMaking.h"

#import "QEADIFFile.h"
#import "QEADIFFileMaker.h"

#define ADIF_SRC1_LF @"\n<CALL:6>cx4aaj\n<BAND:3>15M\n<MODE:4>RTTY\n<QSO_DATE:8>20080928\n<TIME_ON:6>183200\n<FREQ:6>21.106\n<EOR>\n<CALL:4>n2bj\n<BAND:3>40M\n<MODE:5>PSK31\n<QSO_DATE:8>20081004\n<TIME_ON:6>000000\n<FREQ:5>7.072\n<EOR>\n<CALL:5>ai4of\n<BAND:3>40M\n<MODE:5>PSK31\n<QSO_DATE:8>20081004\n<TIME_ON:6>010700\n<FREQ:5>7.072\n<EOR>\n"

@implementation TestADIFFileMaking
- (void)testFileMaking
{
    STAssertTrue(YES, @"CAN'T FAIL");
    
    QEADIFFile *file;
    //    file = [QEADIFFileMaker makeFileFromSource:ADIF_SRC1_LF];
//    file = [QEADIFFileMaker makeADIFFileFromFile:@"/Users/jon/Downloads/lotwreport-1.adi" error:nil];
    file = [QEADIFFileMaker makeADIFFileFromFile:@"/Users/jon/Documents/adif_out.adi" error:nil];

    //-NSLog(@"\n*** DUMP ***\n%@\n", [file dump]);
    [file regenerateHeadersWithApplicationName:@"Chalk"];
    //-NSLog(@"\n*** DUMP ***\n%@\n", [file dump]);
    
    if ([file writeToFile:@"/Users/jon/Documents/adif_out.adi" error:nil]) {
        //-NSLog(@"  write successful");
    } else {
        //-NSLog(@"  write failed");
    } // else

} // testFileMaking
@end
